package Beans;

import javax.servlet.http.HttpServletRequest;

import Helpers.ApplicationConfiguration;

public class RedirectorBean implements java.io.Serializable
{
	public RedirectorBean() {}
	
	private static final long serialVersionUID = 1L;
	
	private HttpServletRequest request;
	private String target;

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	
	public String getTarget() {
		return target;
	}

	private void setTarget(String target) {
		this.target = target;
	}
	
	public void calculateTarget(){
		setTarget(ApplicationConfiguration.getInstance().getTargetInCurrentRedirectorBySource("default").get("target"));
		String pt = request.getParameter("target");
		if(pt != null)
		{
			String t = ApplicationConfiguration.getInstance().getTargetInCurrentRedirectorBySource(pt).get("target");
			if(t != null)
			{
				setTarget(t);
			}
		}
	}
}
